package com.zzz.product.controller;

/*
 * @author zzr
 * @date: 2025/10/15  17:15
 * @description:
 */

import com.zzz.api.ProductInterface;
import com.zzz.model.ProductInfo;
import com.zzz.product.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Slf4j
@RequestMapping("/product")
@RestController
public class ProductController implements ProductInterface{
    @Autowired
    private ProductService productService;

    @RequestMapping("/{productId}")
    public ProductInfo getProductById(@PathVariable("productId") Integer productId) {
        ProductInfo productInfo = productService.selectProductById(productId);
        log.info("收到请求：{}",productId);
        return productInfo;
    }

    @Override
    @RequestMapping("/p1")
    public String p1(Integer id){
        return "product-service 接收到参数, id:"+id;
    }

    @Override
    @RequestMapping("/p2")
    public String p2(Integer id, String name){
        return "product-service 接收到参数, id:"+id+",name:"+name;
    }

    @Override
    @RequestMapping("/p3")
    public String p3(ProductInfo productInfo){
        return "product-service 接收到参数: productInfo"+productInfo.toString();
    }

    @Override
    @RequestMapping("/p4")
    public String p4(@RequestBody ProductInfo productInfo){
        return "product-service 接收到参数: productInfo"+productInfo.toString();
    }
}
